from random import randint
from datetime import datetime   # 引入datetime包可以检验是否为合法日期


def rad_date(): # 生成随机日期函数
    m = randint(1, 12)
    d = randint(1, 31)
    date = (m, d)
    try:    # 如果m,d组成的日期是合法的返回m,d组成的元祖
        datetime(year=1, month=m, day=d)
        return date
    except ValueError:  # 如果经过datetime函数出了错则进入下一次迭代直至成功输出合法日期
        rad_date()


def same_in_23():   #23人中是否有至少两人一样
    date_list = []
    for i in range(23):
        a = rad_date()
        if a:
            date_list.append(a)
    if len(date_list) == len(set(date_list)):   # 通过集合过滤重复元素的性质来判断
        return False
    else:
        return True


count = 0
sample = randint(1000, 2000)    # 样本数量
for i in range(sample):
    if same_in_23():
        count += 1
percentage = count / sample
print(round(percentage, 3))